package com.ruoyi.project.system.item.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.item.domain.OrgEmployee;
import com.ruoyi.project.system.item.mapper.OrgEmployeeMapper;
import com.ruoyi.project.system.item.service.IOrgEmployeeService;
import com.ruoyi.project.system.user.domain.User;
import com.ruoyi.project.system.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.text.Convert;

import javax.annotation.Resource;

/**
 * 员工Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-11-02
 */
@Service
public class OrgEmployeeServiceImpl implements IOrgEmployeeService
{
    @Resource
    private OrgEmployeeMapper orgEmployeeMapper;
    @Autowired
    private IUserService userService;

    /**
     * 查询员工
     * 
     * @param id 员工主键
     * @return 员工
     */
    @Override
    public OrgEmployee selectOrgEmployeeById(String id)
    {
        return orgEmployeeMapper.selectOrgEmployeeById(id);
    }

    /**
     * 查询员工列表
     * 
     * @param orgEmployee 员工
     * @return 员工
     */
    @Override
    public List<OrgEmployee> selectOrgEmployeeList(OrgEmployee orgEmployee)
    {
        return orgEmployeeMapper.selectOrgEmployeeList(orgEmployee);
    }

    /**
     * 新增员工
     * 
     * @param orgEmployee 员工
     * @return 结果
     */
    @Override
    public int insertOrgEmployee(OrgEmployee orgEmployee)
    {
        orgEmployee.setCreateTime(DateUtils.getNowDate());
        // 获取当前的用户信息
        User currentUser = ShiroUtils.getSysUser();
        String loginName = currentUser.getLoginName();
        orgEmployee.setOpBy(loginName);
        return orgEmployeeMapper.insertOrgEmployee(orgEmployee);
    }

    /**
     * 修改员工
     * 
     * @param orgEmployee 员工
     * @return 结果
     */
    @Override
    public int updateOrgEmployee(OrgEmployee orgEmployee)
    {
        return orgEmployeeMapper.updateOrgEmployee(orgEmployee);
    }

    /**
     * 批量删除员工
     * 
     * @param ids 需要删除的员工主键
     * @return 结果
     */
    @Override
    public int deleteOrgEmployeeByIds(String ids)
    {
        return orgEmployeeMapper.deleteOrgEmployeeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除员工信息
     * 
     * @param id 员工主键
     * @return 结果
     */
    @Override
    public int deleteOrgEmployeeById(String id)
    {
        return orgEmployeeMapper.deleteOrgEmployeeById(id);
    }
}
